<?php
/* 
 * Copyright (c) 2018-2021   All rights reserved.
 * 
 * 创建时间：2021-11-06 08:56
 *
 * 项目：rm  -  $  - fmUrlHelper.php
 *
 * 作者：liwei 
 */

namespace modules\levfm\helpers;

use Lev;
use lev\helpers\UrlHelper;

!defined('INLEV') && exit('Access Denied LEV');

class fmUrlHelper
{

    public static function checkData($formid = null)
    {
        return Lev::toReRoute(['admin-datas/check', 'status'=>2, 'formid'=>$formid]);
    }

    public static function formView($opid = null) {
        return Lev::toReWrRoute(['form/view', 'opid'=>$opid]);
    }

    public static function formList($formid = null) {
        return Lev::toReWrRoute(['form/list', 'opid'=>$formid]);
    }

    /**
     * 可以伪静态的 - 显示表单
     * @param null $opid
     * @param null $formid
     * @param null $day 按天统计 默认统计总量
     * @return bool|mixed|string
     *
     * @see fmUrlHelper::addData()
     */
    public static function forms($opid = null, $formid = null, $day = null) {
        return Lev::toReWrRoute(['form', 'opid' => $formid ? 'id'.$formid : $opid, 'day'=>$day]);
    }

    /**
     * 可以伪静态的 - 内容列表页
     * @param null $formid
     * @return bool|mixed|string
     */
    public static function lists($formid = null) {
        return Lev::toReWrRoute(['list/index', 'opid'=>$formid]);
    }

    /**
     * 可以伪静态的 - 内容详情页
     * @param null $opid
     * @return bool|mixed|string
     */
    public static function views($opid = null) {
        return Lev::toReWrRoute(['view', 'opid'=>$opid]);
    }

    public static function formPreview($formid, $preview = 1) {
        return Lev::toReRoute(['form-data', 'form'=>$formid, 'id'=>'levfm', 'preview'=>$preview]);
    }

    public static function formEdit($formid)
    {
        return Lev::toReRoute(['Form_levfm_forms', 'opid'=>$formid, 'id'=>'levfm', 'formid'=>$formid]);
    }

    /**
     * 添加、修改表单数据
     * @param null $opid
     * @param null $formid
     * @return bool|mixed|string
     */
    public static function addData($opid = null, $formid = null, $setup = null) {
        return Lev::toReRoute(['form-data', 'opid'=>$opid, 'form'=>$formid, 'setup' => $setup]);
    }

    /**
     * 添加、修改字段
     * @param $formid
     * @param null $opid
     * @return bool|mixed|string
     */
    public static function addField($formid, $opid = null)
    {
        return Lev::toReRoute(['Form_levfm_fields', 'formid'=>$formid, 'opid'=>$opid, 'id'=>'levfm']);
    }

    /**
     * 表单字段管理URL地址
     * @param $formid
     * @return bool|mixed|string
     */
    public static function fieldManageUrl($formid)
    {
        return Lev::toReRoute(['Form_levfm_forms', 'setup'=>10, 'opid'=>$formid, 'formid'=>$formid, 'id'=>'levfm']);
    }

}